Using material types
Material types define the property type of a material. By adjusting material property values defined by a material type, you set the appearance of a material. Each material type has a vertex shader and a fragment shader, which set the type of properties you can use in a material.
Kanzi Studio provides template projects that contain a default set of material types and shaders from the Kanzi Studio Asset Library located in <KanziInstallation>/Studio/Asset Library. When you create a new Kanzi Studio project you can select from different project templates based on the material types they provide:
- To start with a template that does not contain any predefined material types, select Import material types manually. You can add material types from the Kanzi Studio material library to the project when you need them, or create your own material types. See Adding a material type to your project.
- Fast performance vertex shaders template is intended for low precision and high performance OpenGL ES2 applications. It contains vertex-based shaders optimized for use with OpenGL ES2. Most of the GPU specific computation is done in the vertex shaders. This is a good starting point for most devices.
- High quality fragment shaders template is intended for high precision OpenGL ES2 applications. It contains pixel-shader based materials for use with OpenGL ES2. Most of the GPU specific computation is done in the fragment shaders. This offers better image quality often at the cost of performance.
You can:
Adding a material type to your project
You can add material types to your project in these ways:
- Create a Kanzi default material type.
Kanzi comes with a set of default material types for different purposes. To create a Kanzi default material type that is not already in your project, in the Library > Materials and Textures press Alt and right-click Material Types, and select the material type you want to add.
If you created your project with a template that does not contain any predefined material types, all Kanzi default material types are available for you to add:
- ColorTexture, DefaultBlit, FontDefault, MaskTexture, SweepTextures and Textured are material types with general purpose shaders. Because these shaders are more concerned with functionality and quality than performance, these material types are suitable for development purposes.
- VertexPhong material types are fast-performing material types with vertex-based shaders.
- FragmentPhong material types are slower-performing material types with pixel-based shaders.
Kanzi Studio adds the material type and creates a material using that material type. You can create additional materials from the same material type. See Using materials.
- Add any material type from your computer.
To add to your project any material type from your computer, in the Library right-click Materials and Textures, select Load Material Type From Disk, go to the directory that contains the material type you want to add, select the material type and click Open.
Kanzi Studio adds the material type and creates a material using that material type. You can create additional materials from the same material type. See Using materials.
Modifying the default Phong material types
The default FragmentPhong and VertexPhong material types support these properties:
FragmentPhong, VertexPhong
|
|
|
|
|
|
FragmentPhongCube, VertexPhongCube
|
|
|
x |
|
|
VertexPhongMorph
|
|
|
|
x |
|
FragmentPhongSkinned, VertexPhongSkinned |
|
|
|
|
x |
FragmentPhongTextured, VertexPhongTextured |
x |
|
|
|
|
FragmentPhongTexturedCube, VertexPhongTexturedCube |
x |
|
x |
|
|
FragmentPhongTexturedCubeNormalMap
|
x |
x |
x |
|
|
VertexPhongTexturedMorph
|
x |
|
|
x |
|
FragmentPhongTexturedNormalMap
|
x |
x |
|
|
|
FragmentPhongTexturedSkinned, VertexPhongTexturedSkinned |
x |
|
|
|
x |
|
|
|
|
|
|
To modify a VertexPhong or FragmentPhong material type:
- Select or add to your project one of the default VertexPhong or FragmentPhong material types. See Adding a material type to your project.
For example, in the Library > Materials and Textures > Material Types select the VertexPhong material type.
- In the Properties in the Preprocessor Defines property set the properties of the material type.
You can use this approach only for the FragmentPhong and VertexPhong material types. To modify the properties for other material types, you have to edit the shaders manually. See Editing shaders.
You can set these Preprocessor Defines:- KANZI_SHADER_USE_BASECOLOR_TEXTURE
To enable the use of basecolor texture set the Value to 1, and to disable set the Value to 0. - KANZI_SHADER_USE_NORMALMAP_TEXTURE
To enable the use of normalmap set the Value to 1, and to disable set the Value to 0.
- KANZI_SHADER_USE_REFLECTION_CUBE
To enable the use of cubemap reflections set the Value to 1, and to disable set the Value to 0.
- KANZI_SHADER_USE_MORPHING
To enable morphing set the Value to 1, and to disable set the Value to 0.
See Using Morph resources.
Do not enable both morphing and skinning for the same material type. - KANZI_SHADER_SKINNING_BONE_COUNT
To enable skinning for meshes, set the Value to the number of bones in your skinned mesh.
See Using skinned meshes.
Do not enable both skinning and morphing for the same material type.
- KANZI_SHADER_NUM_DIRECTIONAL_LIGHTS, KANZI_SHADER_NUM_POINT_LIGHTS, and KANZI_SHADER_NUM_SPOT_LIGHTS
To enable the use of the Directional Light, Point Light, and Spot Light nodes, set the Value for each node type to the number of nodes you want to use. See Setting the number of lights for a material type
For example, set the value of KANZI_SHADER_USE_BASECOLOR_TEXTURE to 1 and press the Enter key.
- In the Properties in the Uniforms property Kanzi Studio automatically updates the uniform arrays and if any uniform source types are missing, Kanzi Studio marks them with red type.
In the Properties under the Property Types click Sync with Uniforms to add the missing properties for the materials that use this material type.
Adding a property to a material type
Add a property to a material type to make it suitable for your needs. You can use the material type you customize or create to make it faster and easier to set the appearance of materials in your project. When you add a property to a material type, Kanzi Studio adds the property to all materials using that material type.
To add a property to a material type:
- In the Library > Materials and Textures > Material Types select the material type to which you want to add a property.
- In the Properties in the Input section from the dropdown menu select the property you want to add.
- In the Library > Resource Files > Shaders double-click the shader where you want to use the property to open it in the Shader Source Editor.
- Add the property to the shader code and save the shader. You can use code snippets to declare a uniform by clicking the Uniforms button in the Shader Source Editor. See Editing shaders.
Reusing material types
When you create a material type in your Kanzi Studio project, you can reuse the material type in another Kanzi Studio project.
To reuse material types:
- Save the material type:
- In the Library > Materials and Textures > Material Types right-click the material type that you want to use in another project, and select Save Material Type to Disk.
- Select the name and location where you want to save the material type and click Save.
- Reuse the material type:
- In Kanzi Studio open the project to which you want to load the material type that you saved.
- In the Library right-click Materials and Textures, select Load Material Type From Disk, go to the directory that contains the material type that you saved, select the material type and click Open.
Kanzi Studio adds the material type and creates a material using that material type. You can create additional materials from the same material type. See Using materials.
Material Type property types
For a list of the available property types for material types, see Material type.
See also
Using materials
Material types and materials
Editing shaders
Using Morph resources
Using skinned meshes
Setting the number of lights for a material type
Open topic with navigation